To get started right away without having to build an app from scratch, explore with the Ditto ready-to-use demo task app.
For a complete overview of the platforms, transports, and devices the JavaScript SDK supports, select Node.js from the Directory of Compatibility Maps.
Open the project in your IDE, and then open the index.ts file. For example, if using Visual Studio Code:
bash
Copy
Ask AI
code .
4
In line 14 of the index.ts file, replace ‘YOUR_APP_ID’ and ‘YOUR_TOKEN’ with your app ID and playground token. (See Getting Playground Token Credentials)
bash
Copy
Ask AI
code .
5
In line 14 of the index.ts file, replace ‘YOUR_APP_ID’ and ‘YOUR_TOKEN’ with your app ID and playground token. (See Getting Playground Token Credentials)
TypeScript
Copy
Ask AI
// replace YOUR_APP_ID and YOUR_TOKEN with pditto = new Ditto({ type: 'onlinePlayground', appID: 'YOUR_APP_ID', token: 'YOUR_TOKEN' })
6
Build the demo task app:
bash
Copy
Ask AI
npm run build
7
Interact with the demo task app and simulate real-time peer-to-peer replication by running the demo task app in two or more separate terminals (one for each virtual peer):
bash
Copy
Ask AI
node index.js
8
Using the commands that automatically appear in each of your terminals, add, remove, and modify documents as desired.
9
If you want to observe your changes sync with the cloud-optional deployment, the Big Peer, open the data browser in the Ditto portal.